<template>
  <div>
    <!-- 标题 -->
    <p class="title">推荐歌单</p>
    <!--  -->
    <div>
      <van-row gutter="10">
        <van-col span="8" v-for="obj in recommendList" :key="obj.id"
          ><van-image width="100%" height="100" :src="obj.picUrl" />
          <p class="song_name">{{ obj.name }}</p>
        </van-col>
      </van-row>
    </div>
    <p class="title">最新音乐</p>
    <SongItem
      v-for="obj in hotSongList"
      :key="obj.id"
      :name="obj.name"
      :author="obj.song.artists[0].name + '-' + obj.name"
      :id="obj.id"
    ></SongItem>
  </div>
</template>

<script>
import { recommendMusicApi, hotMusicApi } from "@/api";
import SongItem from "@/components/SongItem.vue";
export default {
  components: {
    SongItem,
  },
  data() {
    return {
      recommendList: [], //推荐歌单
      hotSongList: [], //最新音乐
    };
  },
  //   async created() {
  //     const res = await recommendMusicApi();
  //     console.log(res);
  //   },
  mounted() {
    recommendMusicApi({ limit: 6 }).then((res) => {
      console.log(res);
      if (res.data.code === 200) {
        this.recommendList = res.data.result;
      }
    });
    hotMusicApi({ limit: 20 }).then((songRes) => {
      console.log(songRes);
      if (songRes.data.code === 200) {
        this.hotSongList = songRes.data.result;
      }
    });
  },
};
</script>

<style scoped>
/* 标题 */
.title {
  padding: 0.266667rem 0.24rem;
  margin: 0 0 0.24rem 0;
  background-color: #eee;
  color: #333;
  font-size: 15px;
}
/* 推荐歌单 - 歌名 */
.song_name {
  font-size: 0.346667rem;
  padding: 0 0.08rem;
  margin-bottom: 0.266667rem;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2; /** 显示的行数 **/
  overflow: hidden; /** 隐藏超出的内容 **/
}
.search-icon {
  font-size: 16px;
  line-height: inherit;
}
</style>